<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-员工列表">
</@frame.head>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span>  帮助信息管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
<form method="post" name="query_helpInfo_form"  id="query_helpInfo_form" action="${contextPath}/helpInfo/helpInfo_list" >    
   <input type="hidden" name="page" value="${pagination.pageNo}"  id="page" />                        
    <div class="text-c">
        <table class="table">
           <tr>  
           <td>帮助标题：</td>
           <td><input type="text" class="input-text  radius"  placeholder="帮助标题" id="" name="title" value="${helpInfoQo.title}"></td>     
           <td>帮助分类：</td>
           	   <td>
           
	           <span class="select-box radius">
	           <select class="select"  name="helpCategoryId" id="helpCategoryId">
	           	<option value>全部</option>
				<#list helpCategoryMap?keys as testKey>
				<#if testKey=helpInfoQo.helpCategoryId>
				<option value="${testKey}" selected="selected">${helpCategoryMap[testKey]}</option>
				<#else>
				<option value="${testKey}" >              	${helpCategoryMap[testKey]}
     			</option>
				</#if>
				
				</#list>
	           </select>
	           </span>
	           </td> 
               <td>状态：</td>
           	   <td>
           
	           <span class="select-box radius">
	           <select class="select"  name="state" id="state">
	           	<option value>全部</option>
				<#list stateMap?keys as testKey>
				<#if testKey=helpInfoQo.state>
				<option value="${testKey}" selected="selected">${stateMap[testKey]}</option>
				<#else>
				<option value="${testKey}" >              	${stateMap[testKey]}
     			</option>
				</#if>

				</#list>
	           </select>
	           </span>
	           </td> 
          </tr>
         <tr> 
         <td colspan="6" style="text-align:center;" >
           <input class="btn btn-success radius" type="button"  onclick="search();"  value="搜索" />
         </td>
         </tr>
      </table>
    </div>
</form>

    <div class="cl pd-5 bg-1 bk-gray mt-20"> 
    <span class="l">
     <a href="javascript:;" onclick="add()" class="btn btn-primary radius"> 新增</a> 
    </span>
    <span class="r">共有数据：<strong>${pagination.totalCount}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr  class="text-c">
            <th >帮助标题</th>
            <th >帮助分类</th>
            <th >发布时间</th>
            <#if helpInfoQo.helpCategoryId??  && (helpInfoQo.helpCategoryId?length &gt; 0)>
			<th >
				显示顺序
			</th>
			
            </#if>
            <th >状态</th>
            <th >操作</th>
        </tr>
        </thead>
        <tbody>
       <#if pagination.list?? && (pagination.list?size &gt; 0) >
        <#list pagination.list as helpInfo> 
             <tr  class="text-c">
                <td>${helpInfo.title}</td>
                <td width="55">    
                <#list helpCategoryMap?keys as testKey>
                     <#if helpInfo.helpCategory.id=testKey>
                     ${helpCategoryMap[testKey]}
                     </#if> 
				</#list>                                    
                </td>
                <td>
                ${(helpInfo.createDate?string("yyyy-MM-dd HH:mm:ss"))!}
                </td>
                  <#if helpInfoQo.helpCategoryId?? &&( helpInfoQo.helpCategoryId?length &gt; 0)>
                  <td>
                  <input class="position" type="text" helpInfoId="${helpInfo.id}" value="${helpInfo.position}" />
                  </td>
                  </#if>
                <td width="55">   
                <#list stateMap?keys as testKey>
                     <#if helpInfo.state=testKey>
                    ${stateMap[testKey]}
                     </#if> 
				</#list>                                     
                </td>
                <td>					
     			<a style="color:blue" onclick="look('${helpInfo.id}')">查看</a>&nbsp;&nbsp;
				<a style="color:blue" onclick="edit('${helpInfo.id}')"">修改</a>&nbsp;&nbsp;
				<a style="color:blue" onclick="deleteHelpInfo('${helpInfo.id}')">删除</a>&nbsp;&nbsp;
				<#if helpInfo.state = 1>
					<a style="color:blue;" onclick="hide('${helpInfo.id}')">隐藏</a>&nbsp;&nbsp;
				
				<#else>
					<a style="color:blue;" onclick="show('${helpInfo.id}')">显示</a>&nbsp;&nbsp;
				</#if>											
               </td>
        </tr>
      </#list></#if>
     </tbody>
    </table>
    <div id="div_page" style="padding-top: 10px;float: right"></div>
</div>
<@frame.end "default">
</@frame.end>
</html>
<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/brand/query_brand.js"></script>
<script type="text/javascript">
var path="${contextPath}";
laypage({
    cont: 'div_page',//容器。值支持id名、原生dom对象，jquery对象。
    pages: ${pagination.totalPage},//通过后台拿到的总页数
    curr:  ${pagination.pageNo} || 1, //当前页
	skip: true, //是否开启跳页
	first: 1, //将首页显示为数字1,。若不显示，设置false即可
	last: ${pagination.totalPage}, //将尾页显示为总页数。若不显示，设置false即可
    jump: function(obj , first){//触发分页后的回调
        if(!first){ //点击跳页触发函数;当前页为obj.curr
            $("#page").val(obj.curr);
            $("#query_helpInfo_form").submit();
        }
    }
})  
$(".position").blur(function(){
  	
  	$(".position").unbind("blur");
  	
  	if(confirm("确定修改显示顺序吗")){
  	   focus = true;
  	   var position = $(this).val();
  	   var regText = /^[0-9]*[1-9][0-9]*$/;
         if(!position.match(regText)){
        	 layer.alert("请输入正确的显示顺序");	
		return false;
         }
         
         var helpInfoId = $(this).attr("helpInfoId");
         
     	   var url = path+"/helpInfo/helpInfo_changePosition";
			$.ajax({
			 url : url,
				   type : "post",
				   dataType : "text",
				   data : {
					   "helpInfoId":helpInfoId,
					   "position":position
					},
				   success : function(msg){
					  var resultArr = msg.split(",");
					  if(resultArr[0]=="success"){
						  layer.alert("修改显示顺序成功！");
						  reload();
					  }else{
						  layer.alert(resultArr[1]);
						  reload();
					  }
				  },
			error : function(){
				layer.alert("操作失败");
			 reload();
			}
});
         
         
  	 }else{
  		 reload();
  	 }
  });
function search(){
    $("#page").val("1");
    $("#query_helpInfo_form").submit();
}	
function add(){
	layer_show('添加帮助信息',path+'/helpInfo/helpInfo_toadd','900','750');
}
function edit(id){
	layer_show('修改帮助信息',path+'/helpInfo/helpInfo_edit?id='+id,'800','700');
}
function look(id){
	layer_show('查看帮助信息',path+'/helpInfo/helpInfo_look?id='+id,'800','700');
}
function deleteHelpInfo(helpInfoId){
	if(confirm("确定删除吗")){
		var url = path+"/helpInfo/helpInfo_delete";
		   $.ajax({
			   url : url,
		   	   type : "post",
		   	   dataType : "text",
		   	   data : {"id":helpInfoId},
		   	   success : function(msg){
		   		  if(msg=="success"){
	                    layer.msg('删除成功!',{icon:1,time:1000},function(){
	                        window.location.reload();
	                    });
/* 		   			  alert("删除成功！");
		   			  reload(); */
		   		  }else if(msg=="fail"){
		   			layer.alert("删除失败！");
		   		  }else{
		   			layer.alert("无权限操作！");
		   		  }
		   	  },
			  error : function(){
				  layer.alert("操作失败");
			  }
		   });
	   }
}

function show(helpInfoId){
	if(confirm("确定显示吗")){
		var url = path+"/helpInfo/helpInfo_show";
		   $.ajax({
			   url : url,
		   	   type : "post",
		   	   dataType : "text",
		   	   data : {"id":helpInfoId},
		   	   success : function(msg){
		   		  var resultArr = msg.split(",");
		   		  if(resultArr[0]=="success"){
	                    layer.msg('显示成功!',{icon:1,time:1000},function(){
	                        window.location.reload();
	                    });
/* 		   			layer.alert("显示成功！");
		   			$("#query_helpInfo_form").submit(); */
		   		  }else{
		   			layer.alert(resultArr[1]);
		   		  }
		   	  },
			  error : function(){
				  layer.alert("操作失败");
			  }
		   });
	   }
}

function hide(helpInfoId){
	if(confirm("确定隐藏吗")){
		var url = path+"/helpInfo/helpInfo_hide";
		   $.ajax({
			   url : url,
		   	   type : "post",
		   	   dataType : "text",
		   	   data : {"id":helpInfoId},
		   	   success : function(msg){
		   		  if(msg=="success"){
	                    layer.msg('隐藏成功!',{icon:1,time:1000},function(){
	                        window.location.reload();
	                    });
/* 		   			layer.alert("隐藏成功！");
		   			$("#query_helpInfo_form").submit(); */
		   		  }else{
		   			layer.alert("隐藏失败！");
		   		  }
		   	  },
			  error : function(){
				  layer.alert("操作失败");
			  }
		   });
	   }
}
</script>